<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('出库汇总')"/>
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div id="printArea">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>

                            <li>
                                出库时间：<input type="text" id="today" class="time-input inline"
                                            th:value="${today}"
                                            name="params[outputTime]"/>
                            </li>

                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="msearch()"><i
                                        class="fa fa-search"></i>&nbsp;搜索</a>
                            </li>

                        </ul>
                    </div>
                </form>
                <!--<a class="btn btn-warning fl-r" onclick="$.table.exportExcel()"
                   shiro:hasPermission="system:ncOuputCf:export">
                    <i class="fa fa-download"></i> 导出
                </a>-->
                <a class="btn btn-warning fl-r" id="print-btn" nohide="1" orderType="23">
                    <i class="fa fa-download"></i> 打印
                </a>
            </div>

            <div class="btn-group-sm" id="toolbar-cf" role="group">
                <h3 class="inline">菜房：</h3>

            </div>

            <div class="btn-group-sm" id="toolbar-ck" role="group">
                <h3 class="inline">鸡舍出库：</h3>

            </div>
            <div class="btn-group-sm" id="toolbar-milk" role="group">
                <h3 class="inline">牛舍出库：</h3>

            </div>
            <h3 align="center"> <span th:text="${today}+ 日出库汇总" id="ordercode" hidden="hidden"></span> </h3>

            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table" data-mobile-responsive="true"></table>
            </div>

            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table-ck" data-mobile-responsive="true"></table>
            </div>

            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table-milk" data-mobile-responsive="true"></table>
            </div>
        </div>
    </div>
</div>
<div th:include="include :: footer"></div>
<script th:inline="javascript">
    var datas = [[${@dict.getType('cforderType')}]];
    var prefix = ctx + "system/ncOuputCf";
    var type = [[${type}]];
    $(function () {
        var options = {
            url: prefix + "/listTodays?type=" + type + "&today=" + $('#today').val(),
            createUrl: prefix + "/add",
            updateUrl: prefix + "/edit/{id}",
            removeUrl: prefix + "/remove",
            exportUrl: prefix + "/export?type=" + type,
            modalName: "菜房出库",
            toolbar: 'toolbar-cf',
            showExport: false,
            showSearch: false,
            showRefresh: false,
            showColumns: false,
            showToggle: false,
            showFooter: false,
            pagination: false,
            columns: [{
                title: '序号',
                formatter: function (value, row, index) {
                    return $.table.serialNumber(index);
                },
                footerFormatter: function () {
                    return '合计'
                }

            },
                {
                    field: 'outputId',
                    title: '出库id',
                    visible: false,
                    footerFormatter: function () {
                        return '-'
                    }

                },
                {
                    field: 'ncorderCf.cforderCode',
                    title: '订单编号',
                    formatter: function (value, row, index) {
                        if (row.ncorderCf.isCheck == '1') {
                            return '-'
                        } else {
                            return row.ncorderCf.cforderCode
                        }

                    },
                    footerFormatter: function () {
                        return '-'
                    }


                }, {

                    field: 'piciCode',
                    title: '蔬菜批次',
                    footerFormatter: function () {
                        return '-'
                    }

                },
                {
                    field: 'ncorderCf.cropNameCn',
                    title: '作物名称',
                    footerFormatter: function () {
                        return '-'
                    }

                },
                {
                    field: 'ncorderCf.cropVarietiesCn',
                    title: '作物品种',
                    footerFormatter: function () {
                        return '-'
                    }
                },
                {
                    field: 'teamCn',
                    title: '生产班组',
                    footerFormatter: function () {
                        return '-'
                    }

                },
                {

                    field: 'outputType',
                    title: '出库类型',
                    formatter: function (value, row, index) {
                        return $.table.selectDictLabel(datas, value);
                    },
                    footerFormatter: function () {
                        return '-'
                    }
                },
                {
                    field: 'realAmout',
                    title: '实际提供数量（kg）',
                    sortable: true,
                    footerFormatter: function () {
                        //统计总分数
                        var count = 0;
                        $.each($('#bootstrap-table').bootstrapTable('getData'), function (index, item) {
                            count += item.realAmout;
                        });
                        return count;

                    }
                },
                {
                    field: 'outputTime',
                    title: '出库时间',
                    sortable: true,
                    footerFormatter: function () {
                        return '-'
                    }
                },
                {
                    field: 'outputUser',
                    title: '出库经手人',
                    sortable: true,
                    footerFormatter: function () {
                        return '-'
                    }
                },

                {
                    field: 'remark',
                    title: '备注',
                    footerFormatter: function () {
                        return '-'
                    }
                }]
        };
        $.table.init(options);

        initChicken();
        initMilk();
    });

    function initChicken() {
        var prefix = ctx + "system/ncOutputChicken";
        //出库类型
        var outputType = [[${@dict.getType('outputType')}]];
        //鸡状态
        var chickenStatus = [[${@dict.getType('chickenStatus')}]];
        //宰杀后母鸡标准
        var isHealthy = [[${@dict.getType('isHealthy')}]];

        //初始化下面的table
        var options = {
            url: prefix + "/listTodays?outputStatus=2&today=" + $('#today').val()+"&type="+type,
            createUrl: prefix + "/add",
            updateUrl: prefix + "/edit/{id}",
            removeUrl: prefix + "/remove",
            exportUrl: prefix + "/export",
            modalName: "鸡出库",
            id: 'bootstrap-table-ck',
            toolbar: 'toolbar-ck',
            pagination: false,
            showExport: false,
            showSearch: false,
            showRefresh: false,
            showColumns: false,
            showToggle: false,
            sortName: 'outputTime',
            sortOrder: 'desc',
            showFooter: false,
            columns: [
                {
                    field: 'outputId',
                    title: '入库id',
                    visible: false
                },
                {
                    title: '序号',
                    formatter: function (value, row, index) {
                        return $.table.serialNumber(index);
                    },
                    footerFormatter: function () {
                        return '合计'
                    }
                },
                {
                    field: 'outputTime',
                    title: '出库日期',
                    sortable: true,
                    footerFormatter: function () {
                        return '-'
                    }
                },
                {
                    field: 'requestAmount',
                    title: '需求数量（只）',
                    sortable: true,
                    footerFormatter: function () {
                        //统计总分数
                        var count = 0;
                        $.each($('#bootstrap-table-ck').bootstrapTable('getData'), function (index, item) {
                            count += item.requestAmount;
                        });
                        return count;

                    }
                },
                {
                    field: 'outputAmount',
                    title: '供应数量（只）',
                    sortable: true,
                    footerFormatter: function () {
                        //统计总分数
                        var count = 0;
                        $.each($('#bootstrap-table-ck').bootstrapTable('getData'), function (index, item) {
                            count += item.outputAmount;
                        });
                        return count;

                    }
                },
                {
                    field: 'outputAmountBig',
                    title: '供应大鸡数量（只）',
                    sortable: true,
                    footerFormatter: function () {
                        //统计总分数
                        var count = 0;
                        $.each($('#bootstrap-table-ck').bootstrapTable('getData'), function (index, item) {
                            count += item.outputAmountBig;
                        });
                        return count;

                    }
                },
                {
                    field: 'outputAmountLittle',
                    title: '供应小鸡数量（只）',
                    sortable: true,
                    footerFormatter: function () {
                        //统计总分数
                        var count = 0;
                        $.each($('#bootstrap-table-ck').bootstrapTable('getData'), function (index, item) {
                            count += item.outputAmountLittle;
                        });
                        return count;

                    }
                },
                {
                    field: 'outputType',
                    title: '出库类型',
                    sortable: true,
                    formatter: function (value, row, index) {
                        return $.table.selectDictLabel(outputType, value);
                    },
                    footerFormatter: function () {
                        return '-'
                    }
                }/*,
                {
                    field: 'catchTime',
                    title: '抓鸡时间',
                    sortable: true,
                    footerFormatter: function () {
                        return '-'
                    }
                },
                {
                    field: 'chickenStatus',
                    title: '母鸡状态',
                    sortable: true,
                    formatter: function (value, row, index) {
                        return $.table.selectDictLabel(chickenStatus, value);
                    },
                    footerFormatter: function () {
                        return '-'
                    }
                },
                {
                    field: 'killTime',
                    title: '宰杀时间',
                    sortable: true,
                    footerFormatter: function () {
                        return '-'
                    }
                },
                {
                    field: 'isHealthy',
                    title: '宰杀后成品母鸡标准',
                    sortable: true,
                    formatter: function (value, row, index) {
                        return $.table.selectDictLabel(isHealthy, value);
                    },
                    footerFormatter: function () {
                        return '-'
                    }
                },
                {
                    field: 'butcher',
                    title: '宰杀人员',
                    sortable: true,
                    footerFormatter: function () {
                        return '-'
                    }
                },
                {
                    field: 'receiveTime',
                    title: '菜房接收时间',
                    sortable: true,
                    footerFormatter: function () {
                        return '-'
                    }
                },
                {
                    field: 'receiver',
                    title: '菜房接收人员',
                    sortable: true,
                    footerFormatter: function () {
                        return '-'
                    }
                }*/,
                {
                    field: 'outputUser',
                    title: '出库经手人',
                    sortable: true,
                    footerFormatter: function () {
                        return '-'
                    }
                },
                {
                    field: 'remark',
                    title: '备注',
                    footerFormatter: function () {
                        return '-'
                    }
                }]
        };
        $.table.init(options);

    }

    function initMilk() {
        var prefix = ctx + "system/ncOutputMilk";
        var datas = [[${@dict.getType('outputType')}]];
        var options = {
            url: prefix + "/listTodays?today=" + $('#today').val()+"&type="+type,
            createUrl: prefix + "/add",
            updateUrl: ctx + 'system/ncOutputMilk' + "/edit/{id}",
            removeUrl: ctx + 'system/ncOutputMilk' + "/remove",
            exportUrl: prefix + "/export",
            modalName: "牛奶出库",
            showExport: false,
            showSearch: false,
            showRefresh: false,
            showColumns: false,
            showToggle: false,
            pagination: false,
            id: 'bootstrap-table-milk',
            toolbar: 'toolbar-milk',
            sortName: 'outputTime',
            sortOrder: 'desc',
            showFooter: false,
            columns: [
                {
                    title: '序号',
                    formatter: function (value, row, index) {
                        return $.table.serialNumber(index);
                    },
                    footerFormatter: function () {
                        return '合计'
                    }
                },
                {
                    field: 'cforderCode',
                    title: '牛奶批次',
                    footerFormatter: function () {
                        return '-'
                    }
                },
                {
                    field: 'cropNameCn',
                    title: '产品名称',
                    footerFormatter: function () {
                        return '-'
                    }
                },
                {
                    field: 'outputType',
                    title: '出库类型',
                    sortable: true,
                    formatter: function (value, row, index) {
                        return $.table.selectDictLabel(datas, value);
                    },
                    footerFormatter: function () {
                        return '-'
                    }
                },
                {
                    field: 'requestAmount',
                    title: '需求数量（kg）',
                    sortable: true,
                    footerFormatter: function () {
                        //统计总分数
                        var count = 0;
                        $.each($('#bootstrap-table-milk').bootstrapTable('getData'), function (index, item) {
                            count += item.requestAmount;
                        });
                        return count;

                    }
                },
                {
                    field: 'outputAmout',
                    title: '实际提供数量（kg）',
                    sortable: true,
                    footerFormatter: function () {
                        //统计总分数
                        var count = 0;
                        $.each($('#bootstrap-table-milk').bootstrapTable('getData'), function (index, item) {
                            count += item.outputAmout;
                        });
                        return count;

                    }
                },
                {
                    field: 'outputTime',
                    title: '出库时间',
                    sortable: true,
                    footerFormatter: function () {
                        return '-'
                    }
                },
                {
                    field: 'outputUser',
                    title: '出库经手人',
                    sortable: true,
                    footerFormatter: function () {
                        return '-'
                    }
                },
                {
                    field: 'remark',
                    title: '备注',
                    footerFormatter: function () {
                        return '-'
                    }
                }]
        };
        $.table.init(options);

    }

    function msearch() {
        var url = ctx + 'system/ncOuputCf/ncOuputCfToday?date=' + $('#today').val() + '&type=' + type;
        window.location.href = url;
    }

    function reset() {
        $.form.reset();
        search();
    }

    setTitle("当天出库汇总", true)
</script>
</body>
</html>